﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;

using System.Text;
using System.Windows.Forms;
using Manager.DataAccess;

namespace Manager
{
    public partial class FrmAddDep : DevExpress.XtraEditors.XtraForm
    {
        public FrmAddDep()
        {
            InitializeComponent();
        }

        private void _btnOk_Click(object sender, EventArgs e)
        {
            try
            {
                DataDepartment ddep = new DataDepartment();
                ddep.MaTang = int.Parse(_numMaTang.Value.ToString());
                ddep.TenTang = _txtTenTang.Text;
                ddep.ViTri = int.Parse(_numViTri.Value.ToString());
                ddep.Insert(ddep);
                DialogResult = DialogResult.OK;
                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                DialogResult = DialogResult.Abort;
            }
        }

        private void _btnCancel_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
            Close();
        }
    }
}
